﻿@model ThaireInvestmentWeb.Models.AmortizeScheduleModel
@{
    ViewBag.Title = "AmortizeSchedule";
}
<script>
    $(document).ready(function () {

        $("#PaymentDate").datepicker(
            {
                dateFormat: 'dd/mm/yy',
                showOn: 'button',
                showAnim: 'fadeIn',
                changeMonth: true,
                changeYear: true,
                showButtonPanel: true,
                buttonImage: '@Url.Content("~/Content/images/Calendar.png")'
                
            });
        
       
        

        $("#CancelBtn").click(function (event)
        {
           
            showConfirm(null, CancelBtnAction);
            return false;
        });
        function CancelBtnAction(event)
        {
            
            window.location.href= 'EditFixedIncome?fixedincomeID=@Model.HeaderID';
        }

    });
   
        function del(key)
        {
            showConfirm("ต้องการลบหรือไม่ ?", function ()
            {
                window.location.href= 'DeleteAmortizeSchedule?deleteID='+key;
                closeConfirm();
            });
            return false;

        }
    
    
</script>


<table class="navi" width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
        <td style="width: 100%;">
            <div class="navi">Instrument Type > <a href="fixedIncomeList">Fixed Income List</a>>Header > Amortizing Schedule </div>
        </td>
    </tr>
</table>


<table class="tableheader" width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
        <td height="38" align="center" style="width: 100%; text-align: center;">Fixed Income Securities : Amortizing Schedule</td>
    </tr>
</table>
<table width="951" border="1" align="center">
    <tr>
        <td>


            @Html.Partial("_FixedIncomeHeaderView", Model.HeaderDto)
            <div>&nbsp;</div>

            @using (Html.BeginForm("AmortizeSchedule", "FixedIncome", FormMethod.Post, new { id = "mainForm" }))
            {
                <div style="width: 100%;"  align="center">
                    <div style="width: 550px; border: 1px; overflow: auto;">
                        <table  align="center" cellspacing="2">
                            <tr>
                                <th colspan="3" ><strong>Add Amortizing Payment </strong></th>


                            </tr>
                            <tr>
                                <td width="212">
                                    <div align="right">Payment Date : <span class="error">*</span></div>
                                </td>
                                <td width="8">&nbsp;</td>
                                <td>
                                    @Html.TextBoxFor(x => x.PaymentDate, new { @readonly = "readonly", @value = ThaireInvestmentWeb.Util.WebUtil.FormatDate(Model.PaymentDate) })
                                     @Html.ValidationMessageFor(model => model.PaymentDate)
                                </td>

                            </tr>
                            <tr>
                                <td width="212">
                                    <div align="right">Amortizing Payment : <span class="error">*</span></div>
                                </td>
                                <td width="8">&nbsp;</td>
                                <td>
                                    @Html.TextBoxFor(x => x.AmortizingPayment, new { @class = "inputNumberField" })
                                        @Html.ValidationMessageFor(model => model.AmortizingPayment)

                                </td>

                            </tr>
                            <tr>
                                <td colspan="3">
                                    <div align="center">

                                        <input id="SubmitBtn" type="submit" name="BtnSubmit" value=" Submit " class="button" need-confirm="true">
                                        &nbsp;&nbsp; 
                                    &nbsp;&nbsp; 
                                    <input id="CancelBtn" type="button" name="CancelBtn" value=" Cancel " class="button">
                                    </div>
                                </td>
                            </tr>
                        </table>





                        @if (Model.ScheduleList != null && Model.ScheduleList.Count > 0)
                        {
                            var grid = new WebGrid(source: Model.ScheduleList, ajaxUpdateContainerId :"gridselected", rowsPerPage: 25, canSort: false);
                            @grid.GetHtml(htmlAttributes: new { id = "gridselected" }, tableStyle: "tablelist", headerStyle: "headertable", displayHeader: @Model.ScheduleList.Count > 0,
            columns: grid.Columns(

                grid.Column(header: "NO.", format: item => (item.WebGrid.Rows.IndexOf(item) + 1) + (grid.PageIndex * grid.RowsPerPage), canSort: false),
                grid.Column(header: "Payment Date", format: @<text> @ThaireInvestmentWeb.Util.WebUtil.FormatDate(item.PaymentDate) </text>),
                grid.Column(header: "Amortizing Payment", style: "columnNumber", format: @<text> @ThaireInvestmentWeb.Util.WebUtil.FormatDecimal2Digit(item.Payment) </text>),
                grid.Column(header: "ลบ", canSort: false, format: @<text>
                            <input type="image" id="BtnDelete"  = true name="BtnDelete"  onclick="return del('@item.FixincomesecuritiesAmortizeScheduleID    ')"  value="@item.FixincomesecuritiesAmortizeScheduleID" src="@Url.Content("~/Content/images/delete.png")"  title="ลบ"></text>)

                        ));


                        }


                    </div>
                </div>
                         <a name="grid-anchor"></a>
                <script type="text/javascript">
                    $(function () {
                        $('th a, tfoot a').live('click', function () {
                            $(this).attr('href', '#grid-anchor');
                        });
                    });
                </script>
                
                @Html.HiddenFor(x => x.HeaderID);
                @Html.HiddenFor(x => x.DeleteID);
            }

            <br>
        </td>
    </tr>
</table>





